﻿CREATE PROCEDURE [dbo].[Share_Get]
	@shareId NVARCHAR(64)
AS
BEGIN
	IF NOT EXISTS (SELECT * FROM [dbo].[mark_Share] WHERE [ShareId] = @shareId)
	BEGIN
		RAISERROR ('UnknownShareId', 9, 1)
		RETURN
	END

	SELECT TOP 1 c.[HashTag], st.[TextId]
	FROM [dbo].[mark_Share_Text] AS st
	INNER JOIN [dbo].[text_Text] AS t ON t.[TextId] = st.[TextId]
	INNER JOIN [dbo].[text_Chapter] AS c ON c.[ChapterId] = t.[ChapterId]
	WHERE [ShareId] = @shareId
	ORDER BY t.[Order]

END